<?php

namespace app\adminapi\lists\game;

use app\adminapi\lists\BaseAdminDataLists;
use app\common\lists\ListsSearchInterface;
use app\common\lists\ListsSortInterface;
use app\common\model\game\Banner;

/**
 * 列表
 * Class BannerLists
 * @package app\adminapi\lists\softwarelists
 */
class BannerLists extends BaseAdminDataLists implements ListsSearchInterface, ListsSortInterface
{

    /**
     * @notes  设置搜索条件
     * @return array
     * @date 2024/7/14 22:32
     */
    public function setSearch(): array
    {
        return [
            '%like%' => ['title'],
            '=' => ['is_show']
        ];
    }

    /**
     * @notes  设置支持排序字段
     * @return array
     * @date 2024/7/14 22:32
     */
    public function setSortFields(): array
    {
        return ['create_time' => 'create_time', 'id' => 'id'];
    }

    /**
     * @notes  设置默认排序
     * @return array
     * @date 2024/7/14 22:32
     */
    public function setDefaultOrder(): array
    {
        return ['sort' => 'desc', 'id' => 'desc'];
    }

    /**
     * @notes  获取管理列表
     * @return array
     * @date 2024/7/14 22:32
     */
    public function lists(): array
    {
        $lists = Banner::where($this->searchWhere)
            ->append(['show_desc'])
            ->limit($this->limitOffset, $this->limitLength)
            ->order($this->sortOrder)
            ->select()
            ->toArray();

        return $lists;
    }

    /**
     * @notes  获取数量
     * @return int
     * @date 2024/7/14 22:32
     */
    public function count(): int
    {
        return Banner::where($this->searchWhere)->count();
    }

    public function extend()
    {
        return [];
    }
}